package com.esri.android.map;

import android.content.Context;
import android.content.res.XmlResourceParser;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.Shape;
import android.util.Xml;
import android.view.MotionEvent;
import android.view.View;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import com.esri.core.geometry.Geometry;
import com.esri.core.geometry.Point;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.xmlpull.v1.XmlPullParserException;

@Deprecated
/* loaded from: classes.dex */
public class CalloutPopupWindow {
    static final String a = "CalloutPopupWindow";
    private static final int c = 20;
    private static final int d = 6;
    private static List<CalloutPopupWindow> o = Collections.synchronizedList(new ArrayList());
    private static CalloutPopupWindow p;
    private PopupWindow b;
    private Point e;
    private int f;
    private int g;
    private int h;
    private int i;
    private View j;
    private RelativeLayout k;
    private int[] l;
    private MODE m;
    private boolean n;
    private a q;
    private Point r;
    private int s;
    private int t;
    private GraphicsLayer u;
    private int v;
    private int w;
    private int x;
    private boolean y;

    /* loaded from: classes.dex */
    public enum MODE {
        CLIP,
        OVERFLOW
    }

    public CalloutPopupWindow(View view) {
        this(view, MODE.CLIP, null);
    }

    public CalloutPopupWindow(View view, MODE mode) {
        this(view, mode, null);
    }

    public CalloutPopupWindow(View view, MODE mode, CalloutStyle calloutStyle) {
        this.l = new int[2];
        this.m = MODE.CLIP;
        this.v = -1;
        this.w = -1;
        this.x = -1;
        this.y = false;
        this.j = view;
        a(view);
        this.m = mode == null ? MODE.CLIP : mode;
        this.b = new PopupWindow(new View(view.getContext()));
        this.q = new a(calloutStyle);
        this.b.setBackgroundDrawable(new ShapeDrawable(this.q));
    }

    private void b() {
        if (this.y) {
            return;
        }
        this.j.setLayoutParams(new RelativeLayout.LayoutParams(-2, -2));
        this.j.measure(0, 0);
        this.h = (int) Math.max(ANCHOR.b * 4.0f, this.j.getMeasuredWidth());
        this.i = (int) Math.max(ANCHOR.b * 4.0f, this.j.getMeasuredHeight());
    }

    public void setAnchor(int i) {
        this.q.a(i);
    }

    public void setSize(int i, int i2) {
        this.y = true;
        this.h = i;
        this.i = i2;
    }

    public void setMaxWidth(int i) {
        this.s = i;
    }

    public void setMaxHeight(int i) {
        this.t = i;
    }

    public int getMaxWidth() {
        return this.s;
    }

    public int getMaxHeight() {
        return this.t;
    }

    public void setCoordinates(Point point) {
        this.e = point;
    }

    public Point getCoordinates() {
        return this.e;
    }

    public void setContent(View view) {
        this.j = view;
        a(view);
        if (isShowing()) {
            this.k.removeAllViews();
            int[] a2 = this.q.a().a();
            int[] d2 = d();
            RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(d2[0], d2[1]);
            layoutParams.setMargins(a2[0], a2[1], a2[2], a2[3]);
            this.k.addView(view, layoutParams);
            refresh();
        }
    }

    private void a(View view) {
        view.setPadding(view.getPaddingLeft() > 6 ? view.getPaddingLeft() : 6, view.getPaddingTop() > 6 ? view.getPaddingTop() : 6, view.getPaddingRight() > 6 ? view.getPaddingRight() : 6, view.getPaddingBottom() > 6 ? view.getPaddingBottom() : 6);
    }

    public void setOffset(int i, int i2) {
        this.f = i;
        this.g = i2;
    }

    public int[] getOffset() {
        return new int[]{this.f, this.g};
    }

    public void setStyle(CalloutStyle calloutStyle) {
        if (calloutStyle == null) {
            return;
        }
        this.q.a(calloutStyle);
    }

    public void setStyle(Context context, int i) {
        if (i != -1) {
            XmlResourceParser xml = context.getResources().getXml(i);
            while (true) {
                try {
                    if (xml.getEventType() == 2 && xml.getName().equals("calloutViewStyle")) {
                        break;
                    }
                    xml.next();
                } catch (IOException e) {
                    e.printStackTrace();
                } catch (XmlPullParserException e2) {
                    e2.printStackTrace();
                }
            }
            setStyle(new CalloutStyle(context, Xml.asAttributeSet(xml)));
            return;
        }
        setStyle(new CalloutStyle(context));
    }

    public CalloutStyle getStyle() {
        return this.q.c();
    }

    public boolean isShowing() {
        return this.b.isShowing() && !this.n;
    }

    public void showCallout(MapView mapView) {
        showCallout(mapView, this.e, this.f, this.g);
    }

    public void showCallout(MapView mapView, Point point, int i, int i2) {
        if (this.b.isShowing() || this.n) {
            this.b.dismiss();
            this.n = false;
        }
        if (!o.contains(this)) {
            o.add(this);
        }
        this.e = point;
        mapView.getLocationOnScreen(this.l);
        this.r = mapView.toScreenPoint(this.e);
        if (this.q.c() == null) {
            this.q.a(mapView.l.getStyle());
        }
        int[] d2 = d();
        if (this.q.b()) {
            a aVar = this.q;
            aVar.a(aVar.a().adjust(mapView.d, mapView.e, (int) this.r.getX(), (int) this.r.getY(), d2[0], d2[1]));
        }
        if (a(mapView, (int) this.r.getX(), (int) this.r.getY())) {
            this.n = true;
            return;
        }
        this.f = i;
        this.g = i2;
        this.b.setClippingEnabled(false);
        int[] c2 = c();
        this.b.setWidth(c2[0]);
        this.b.setHeight(c2[1]);
        int[] a2 = this.q.a().a(c2[0], c2[1]);
        this.w = ((int) this.r.getX()) + a2[0] + i + this.l[0];
        int y = ((((int) this.r.getY()) + a2[1]) - i2) + this.l[1];
        this.x = y;
        this.b.showAtLocation(mapView, 0, this.w, y);
    }

    public void setMode(MODE mode) {
        this.m = mode;
    }

    public static void removeAll() {
        Iterator<CalloutPopupWindow> it = o.iterator();
        while (it.hasNext()) {
            CalloutPopupWindow next = it.next();
            if (next != null) {
                next.b.dismiss();
            }
            it.remove();
        }
    }

    public void refresh() {
        if (!this.b.isShowing() || this.n) {
            return;
        }
        this.k.invalidate();
        int[] d2 = d();
        int[] a2 = this.q.a().a(d2[0], d2[1]);
        this.b.update(((int) this.r.getX()) + a2[0] + this.f + this.l[0], ((((int) this.r.getY()) + a2[1]) - this.g) + this.l[1], d2[0], d2[1]);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public int[] c() {
        int[] a2 = this.q.a().a();
        int[] d2 = d();
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(d2[0], d2[1]);
        layoutParams.setMargins(a2[0], a2[1], a2[2], a2[3]);
        if (this.k == null) {
            RelativeLayout relativeLayout = new RelativeLayout(this.j.getContext());
            this.k = relativeLayout;
            relativeLayout.addView(this.j, layoutParams);
            this.b.setContentView(this.k);
        } else {
            this.j.setLayoutParams(layoutParams);
            this.k.invalidate();
        }
        return d2;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static int a() {
        List<CalloutPopupWindow> list = o;
        if (list == null) {
            return 0;
        }
        return list.size();
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static void a(MapView mapView) {
        for (CalloutPopupWindow calloutPopupWindow : o) {
            calloutPopupWindow.b(mapView);
        }
    }

    private void b(final MapView mapView) {
        if (this.e == null || !mapView.isLoaded()) {
            return;
        }
        if (this.b.isShowing() || this.n) {
            mapView.post(new Runnable() { // from class: com.esri.android.map.CalloutPopupWindow.1
                @Override // java.lang.Runnable
                public void run() {
                    CalloutPopupWindow calloutPopupWindow = CalloutPopupWindow.this;
                    calloutPopupWindow.r = mapView.toScreenPoint(calloutPopupWindow.e);
                    mapView.getLocationOnScreen(CalloutPopupWindow.this.l);
                    ANCHOR a2 = CalloutPopupWindow.this.q.a();
                    int[] d2 = CalloutPopupWindow.this.d();
                    ANCHOR adjust = CalloutPopupWindow.this.q.b() ? a2.adjust(mapView.d, mapView.e, (int) CalloutPopupWindow.this.r.getX(), (int) CalloutPopupWindow.this.r.getY(), d2[0], d2[1]) : a2;
                    int[] a3 = adjust.a(d2[0], d2[1]);
                    int x = ((int) CalloutPopupWindow.this.r.getX()) + a3[0] + CalloutPopupWindow.this.f + CalloutPopupWindow.this.l[0];
                    int y = ((((int) CalloutPopupWindow.this.r.getY()) + a3[1]) - CalloutPopupWindow.this.g) + CalloutPopupWindow.this.l[1];
                    CalloutPopupWindow calloutPopupWindow2 = CalloutPopupWindow.this;
                    if (calloutPopupWindow2.a(mapView, (int) calloutPopupWindow2.r.getX(), (int) CalloutPopupWindow.this.r.getY())) {
                        CalloutPopupWindow.this.b.dismiss();
                        CalloutPopupWindow.this.n = true;
                    } else if (CalloutPopupWindow.this.n) {
                        CalloutPopupWindow.this.n = false;
                        if (CalloutPopupWindow.this.k == null) {
                            CalloutPopupWindow.this.c();
                        }
                        CalloutPopupWindow.this.b.showAtLocation(mapView, 0, x, y);
                    } else {
                        if (a2 != adjust) {
                            CalloutPopupWindow.this.q.a(adjust);
                        }
                        int[] c2 = CalloutPopupWindow.this.c();
                        CalloutPopupWindow.this.b.update(x, y, c2[0], c2[1]);
                    }
                }
            });
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public int[] d() {
        b();
        int i = this.s;
        int min = i > 0 ? Math.min(i, this.h) : this.h;
        int i2 = this.t;
        int min2 = i2 > 0 ? Math.min(i2, this.i) : this.i;
        int[] a2 = this.q.a().a();
        return new int[]{min + a2[0] + a2[2], min2 + a2[1] + a2[3]};
    }

    /* JADX INFO: Access modifiers changed from: private */
    public boolean a(MapView mapView, int i, int i2) {
        if (this.m == MODE.CLIP) {
            return i < 0 || i2 < 0 || i > mapView.d || i2 > mapView.e;
        }
        int[] d2 = d();
        return d2[0] + i < 0 || d2[1] + i2 < 0 || i - d2[0] > mapView.d || i2 - d2[1] > mapView.e;
    }

    public void hide() {
        if (this.b.isShowing()) {
            this.b.dismiss();
        }
        if (o.contains(this)) {
            o.remove(this);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static class a extends Shape {
        private ANCHOR a;
        private CalloutStyle b;
        private boolean c;
        private float[] d;
        private boolean e;

        public a(CalloutStyle calloutStyle) {
            a(calloutStyle);
        }

        void a(ANCHOR anchor) {
            if (this.c) {
                this.a = anchor;
            }
        }

        void b(ANCHOR anchor) {
            this.a = anchor;
            if (anchor == ANCHOR.FLOATING) {
                this.a = ANCHOR.LOWER_MIDDLE;
                this.c = true;
                return;
            }
            this.c = false;
        }

        void a(int i) {
            b(ANCHOR.a(i));
        }

        public void a(CalloutStyle calloutStyle) {
            if (calloutStyle == null) {
                return;
            }
            this.b = calloutStyle;
            a(calloutStyle.getAnchor());
        }

        /* JADX INFO: Access modifiers changed from: private */
        public CalloutStyle c() {
            return this.b;
        }

        ANCHOR a() {
            return this.a;
        }

        boolean b() {
            return this.c;
        }

        @Override // android.graphics.drawable.shapes.Shape
        public void draw(Canvas canvas, Paint paint) {
            Rect clipBounds = canvas.getClipBounds();
            RectF b = this.a.b(clipBounds);
            paint.setAntiAlias(true);
            this.d = this.a.a(clipBounds);
            Path path = new Path();
            float min = Math.min(this.b.getCornerCurve() * 2, ((int) Math.min(b.bottom - b.top, b.right - b.left)) / 2);
            RectF rectF = new RectF(0.0f, 0.0f, min, min);
            rectF.offsetTo(b.left, b.top);
            if (this.a == ANCHOR.UPPER_LEFT_CORNER) {
                float[] fArr = this.d;
                path.moveTo(fArr[4], fArr[5]);
                a(this.d, path);
            } else {
                path.addArc(rectF, 180.0f, 90.0f);
            }
            if (this.a == ANCHOR.UPPER_MIDDLE) {
                a(this.d, path);
            }
            rectF.offsetTo(b.right - min, b.top);
            if (this.a == ANCHOR.UPPER_RIGHT_CORNER) {
                a(this.d, path);
            } else {
                path.arcTo(rectF, 270.0f, 90.0f);
            }
            if (this.a == ANCHOR.RIGHT_MIDDLE) {
                a(this.d, path);
            }
            rectF.offsetTo(b.right - min, b.bottom - min);
            if (this.a == ANCHOR.LOWER_RIGHT_CORNER) {
                a(this.d, path);
            } else {
                path.arcTo(rectF, 0.0f, 90.0f);
            }
            if (this.a == ANCHOR.LOWER_MIDDLE) {
                a(this.d, path);
            }
            rectF.offsetTo(b.left, b.bottom - min);
            if (this.a == ANCHOR.LOWER_LEFT_CORNER) {
                a(this.d, path);
            } else {
                path.arcTo(rectF, 90.0f, 90.0f);
            }
            if (this.a == ANCHOR.LEFT_MIDDLE) {
                a(this.d, path);
            }
            path.close();
            paint.setStyle(Paint.Style.FILL);
            paint.setColor(this.b.getBackgroundColor());
            paint.setAlpha(this.b.getBackgroundAlpha());
            canvas.drawPath(path, paint);
            paint.setStyle(Paint.Style.STROKE);
            if (this.e) {
                paint.setColor(-16711681);
                paint.setStrokeWidth(3.0f);
            } else {
                paint.setColor(this.b.getFrameColor());
                paint.setStrokeWidth(1.0f);
            }
            canvas.drawPath(path, paint);
        }

        private void a(float[] fArr, Path path) {
            path.lineTo(fArr[4], fArr[5]);
            path.lineTo(fArr[2], fArr[3]);
            path.lineTo(fArr[0], fArr[1]);
        }

        public void a(boolean z) {
            this.e = z;
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public enum ANCHOR {
        UPPER_LEFT_CORNER,
        UPPER_MIDDLE,
        UPPER_RIGHT_CORNER,
        RIGHT_MIDDLE,
        LOWER_RIGHT_CORNER,
        LOWER_MIDDLE,
        LOWER_LEFT_CORNER,
        LEFT_MIDDLE,
        FLOATING;
        
        static final int a = 20;
        static final float b;
        static final float c;

        static {
            float sin = ((float) (20.0d / Math.sin(1.0471975511965976d))) / 2.0f;
            b = sin;
            double d2 = sin * 2.0f;
            double sin2 = Math.sin(0.7853981633974483d);
            Double.isNaN(d2);
            c = ((float) (d2 * sin2)) + 20.0f;
        }

        static ANCHOR a(int i) {
            switch (i) {
                case 0:
                    return UPPER_LEFT_CORNER;
                case 1:
                    return UPPER_MIDDLE;
                case 2:
                    return UPPER_RIGHT_CORNER;
                case 3:
                    return RIGHT_MIDDLE;
                case 4:
                    return LOWER_RIGHT_CORNER;
                case 5:
                    return LOWER_MIDDLE;
                case 6:
                    return LOWER_LEFT_CORNER;
                case 7:
                    return LEFT_MIDDLE;
                case 8:
                    return FLOATING;
                default:
                    return LOWER_LEFT_CORNER;
            }
        }

        /* JADX INFO: Access modifiers changed from: private */
        public int[] a() {
            switch (AnonymousClass2.a[ordinal()]) {
                case 1:
                    return new int[]{20, 10, 0, 10};
                case 2:
                    return new int[]{0, 10, 20, 10};
                case 3:
                    return new int[]{0, 0, 0, 20};
                case 4:
                    return new int[]{0, 20, 0, 0};
                case 5:
                    return new int[]{20, 0, 0, 20};
                case 6:
                    return new int[]{20, 20, 0, 0};
                case 7:
                    return new int[]{0, 20, 20, 0};
                case 8:
                    return new int[]{0, 0, 20, 20};
                default:
                    return new int[]{0, 0, 0, 0};
            }
        }

        public ANCHOR adjust(int i, int i2, int i3, int i4, int i5, int i6) {
            switch (AnonymousClass2.a[ordinal()]) {
                case 1:
                    if (i3 + i5 > i) {
                        return RIGHT_MIDDLE;
                    }
                    int i7 = i6 / 2;
                    if (i4 + i7 > i2) {
                        return LOWER_LEFT_CORNER;
                    }
                    return i4 < i7 ? UPPER_LEFT_CORNER : this;
                case 2:
                    if (i3 < i5) {
                        return LEFT_MIDDLE;
                    }
                    int i8 = i6 / 2;
                    if (i4 + i8 > i2) {
                        return LOWER_RIGHT_CORNER;
                    }
                    return i4 < i8 ? UPPER_RIGHT_CORNER : this;
                case 3:
                    int i9 = i5 / 2;
                    if (i3 < i9) {
                        return LOWER_LEFT_CORNER;
                    }
                    if (i3 + i9 > i) {
                        return LOWER_RIGHT_CORNER;
                    }
                    return i4 < i6 ? UPPER_MIDDLE : this;
                case 4:
                    int i10 = i5 / 2;
                    if (i3 < i10) {
                        return UPPER_LEFT_CORNER;
                    }
                    if (i3 + i10 > i) {
                        return UPPER_RIGHT_CORNER;
                    }
                    return i4 + i6 > i2 ? LOWER_MIDDLE : this;
                case 5:
                    if (i3 + i5 > i) {
                        return LOWER_MIDDLE;
                    }
                    return i4 < i6 ? LEFT_MIDDLE : this;
                case 6:
                    if (i3 + i5 > i) {
                        return UPPER_MIDDLE;
                    }
                    return i4 + i6 > i2 ? LEFT_MIDDLE : this;
                case 7:
                    if (i3 < i5) {
                        return UPPER_MIDDLE;
                    }
                    return i4 + i6 > i2 ? RIGHT_MIDDLE : this;
                case 8:
                    if (i3 < i5) {
                        return LOWER_MIDDLE;
                    }
                    return i4 < i6 ? RIGHT_MIDDLE : this;
                default:
                    return this;
            }
        }

        /* JADX INFO: Access modifiers changed from: private */
        public float[] a(Rect rect) {
            int i = rect.left;
            int i2 = rect.bottom;
            int i3 = rect.right;
            int i4 = rect.top;
            switch (AnonymousClass2.a[ordinal()]) {
                case 1:
                    float f = i + 20;
                    float f2 = (i2 - i4) / 2;
                    float f3 = b;
                    return new float[]{f, f2 - f3, 0.0f, f2, f, f2 + f3};
                case 2:
                    float f4 = i3 - 20;
                    float f5 = (i2 - i4) / 2;
                    float f6 = b;
                    return new float[]{f4, f5 + f6, i3, f5, f4, f5 - f6};
                case 3:
                    float f7 = i + ((i3 - i) / 2);
                    float f8 = b;
                    float f9 = i2 - 20;
                    return new float[]{f7 - f8, f9, f7, i2, f7 + f8, f9};
                case 4:
                    float f10 = i + ((i3 - i) / 2);
                    float f11 = b;
                    float f12 = i4 + 20;
                    return new float[]{f10 + f11, f12, f10, i4, f10 - f11, f12};
                case 5:
                    float f13 = i2;
                    float f14 = c;
                    float f15 = i;
                    return new float[]{i + 20, f13 - f14, f15, f13, f15 + f14, (float) (i2 - 20)};
                case 6:
                    float f16 = i;
                    float f17 = c;
                    float f18 = i4;
                    return new float[]{f16 + f17, i4 + 20, f16, f18, i + 20, f18 + f17};
                case 7:
                    float f19 = i4;
                    float f20 = c;
                    float f21 = i3;
                    return new float[]{(float) (i3 - 20), f19 + f20, f21, f19, f21 - f20, i4 + 20};
                case 8:
                    float f22 = i3;
                    float f23 = c;
                    float f24 = i2;
                    return new float[]{f22 - f23, (float) (i2 - 20), f22, f24, (float) (i3 - 20), f24 - f23};
                default:
                    float f25 = i + ((i3 - i) / 2);
                    float f26 = b;
                    float f27 = i2 - 20;
                    return new float[]{f25 - f26, f27, f25, i2, f25 + f26, f27};
            }
        }

        /* JADX INFO: Access modifiers changed from: private */
        public RectF b(Rect rect) {
            switch (AnonymousClass2.a[ordinal()]) {
                case 1:
                    return new RectF(rect.left + 20, rect.top + 10, rect.right, rect.bottom - 10);
                case 2:
                    return new RectF(rect.left, rect.top + 10, rect.right - 20, rect.bottom - 10);
                case 3:
                    return new RectF(rect.left, rect.top, rect.right, rect.bottom - 20);
                case 4:
                    return new RectF(rect.left, rect.top + 20, rect.right, rect.bottom);
                case 5:
                    return new RectF(rect.left + 20, rect.top, rect.right, rect.bottom - 20);
                case 6:
                    return new RectF(rect.left + 20, rect.top + 20, rect.right, rect.bottom);
                case 7:
                    return new RectF(rect.left, rect.top + 20, rect.right - 20, rect.bottom);
                case 8:
                    return new RectF(rect.left, rect.top, rect.right - 20, rect.bottom - 20);
                default:
                    return new RectF(rect.left, rect.top, rect.right, rect.bottom - 20);
            }
        }

        /* JADX INFO: Access modifiers changed from: private */
        public int[] a(int i, int i2) {
            switch (AnonymousClass2.a[ordinal()]) {
                case 1:
                    return new int[]{0, (-i2) / 2};
                case 2:
                    return new int[]{-i, (-i2) / 2};
                case 3:
                    return new int[]{(-i) / 2, -i2};
                case 4:
                    return new int[]{(-i) / 2, 0};
                case 5:
                    return new int[]{0, -i2};
                case 6:
                default:
                    return new int[]{0, 0};
                case 7:
                    return new int[]{-i, 0};
                case 8:
                    return new int[]{-i, -i2};
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* renamed from: com.esri.android.map.CalloutPopupWindow$2  reason: invalid class name */
    /* loaded from: classes.dex */
    public static /* synthetic */ class AnonymousClass2 {
        static final /* synthetic */ int[] a;

        static {
            int[] iArr = new int[ANCHOR.values().length];
            a = iArr;
            try {
                iArr[ANCHOR.LEFT_MIDDLE.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                a[ANCHOR.RIGHT_MIDDLE.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                a[ANCHOR.LOWER_MIDDLE.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                a[ANCHOR.UPPER_MIDDLE.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                a[ANCHOR.LOWER_LEFT_CORNER.ordinal()] = 5;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                a[ANCHOR.UPPER_LEFT_CORNER.ordinal()] = 6;
            } catch (NoSuchFieldError unused6) {
            }
            try {
                a[ANCHOR.UPPER_RIGHT_CORNER.ordinal()] = 7;
            } catch (NoSuchFieldError unused7) {
            }
            try {
                a[ANCHOR.LOWER_RIGHT_CORNER.ordinal()] = 8;
            } catch (NoSuchFieldError unused8) {
            }
        }
    }

    public static boolean onLongPress(MotionEvent motionEvent) {
        for (CalloutPopupWindow calloutPopupWindow : o) {
            if (calloutPopupWindow.isShowing()) {
                double x = calloutPopupWindow.r.getX();
                double x2 = motionEvent.getX();
                Double.isNaN(x2);
                double d2 = x - x2;
                double y = calloutPopupWindow.r.getY();
                double y2 = motionEvent.getY();
                Double.isNaN(y2);
                double d3 = y - y2;
                double sqrt = Math.sqrt((d2 * d2) + (d3 * d3));
                int i = calloutPopupWindow.v;
                if (i <= 0) {
                    i = 20;
                }
                if (sqrt < i) {
                    p = calloutPopupWindow;
                    calloutPopupWindow.q.a(true);
                    p.refresh();
                    return true;
                }
            }
        }
        return false;
    }

    public static void onDragPointerMove(MapView mapView, MotionEvent motionEvent) {
        CalloutPopupWindow calloutPopupWindow = p;
        if (calloutPopupWindow != null) {
            calloutPopupWindow.e = mapView.toMapPoint(motionEvent.getX(), motionEvent.getY());
            p.b(mapView);
        }
    }

    public static void onDragPointerUp(MapView mapView, MotionEvent motionEvent) {
        CalloutPopupWindow calloutPopupWindow = p;
        if (calloutPopupWindow != null) {
            calloutPopupWindow.e = mapView.toMapPoint(motionEvent.getX(), motionEvent.getY());
            GraphicsLayer graphicsLayer = p.u;
            if (graphicsLayer != null) {
                float x = motionEvent.getX();
                float y = motionEvent.getY();
                int i = p.v;
                if (i <= 0) {
                    i = 20;
                }
                int[] graphicIDs = graphicsLayer.getGraphicIDs(x, y, i, 1);
                if (graphicIDs != null && graphicIDs.length > 0) {
                    Geometry geometry = p.u.getGraphic(graphicIDs[0]).getGeometry();
                    if (Geometry.isPoint(geometry.getType().value())) {
                        p.e = (Point) geometry;
                    }
                }
            }
            p.q.a(false);
            p.refresh();
            p = null;
        }
    }

    public void setSnappingLayer(GraphicsLayer graphicsLayer) {
        this.u = graphicsLayer;
    }

    public void setTolerance(int i) {
        if (i > -1) {
            this.v = i;
        }
    }
}
